package com.bjpowernode.mvc.controller;

import cn.hutool.core.bean.BeanUtil;
import com.bjpowernode.mvc.model.dto.statics.AppStaticsDTO;
import com.bjpowernode.mvc.model.response.Response;
import com.bjpowernode.mvc.model.vo.AppStaticsVO;
import com.bjpowernode.mvc.service.inter.StaticService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


/*@CrossOrigin   //跨域.*/
@RestController
public class AppStaticsController {

    //统计三项基本数据.

    @Resource
    private StaticService service;
    @GetMapping(value = "/app/statics")
    public Response getAppInfo(){
        AppStaticsDTO appStaticsDTO=service.queryAppInfo();

        //将DTO转为VO

        /*老方法*/
       /* AppStaticsVO appStaticsVO=new AppStaticsVO();
        appStaticsVO.setUserCount(appStaticsDTO.getUserCount());
        appStaticsVO.setAllBidMoney(appStaticsDTO.getAllBidMoney());
        appStaticsVO.setProductAvgRate(appStaticsDTO.getProductAvgRate());*/

        /*hutool库方法代替*/
        AppStaticsVO appStaticsVO = BeanUtil.copyProperties(appStaticsDTO, AppStaticsVO.class);

        return Response.ok(appStaticsVO);
    }
}
